const babel = require("@babel/core");
const schema = require("./schema.json")

module.exports = function (content) {
    // 使用异步 loader
    const callback = this.async()
    const options = this.getOptions(schema)
    //使用 babel 转义代码
    babel.transform(content, options, (error, result) => {
        if (error) {
            callback(error, result.code)
        } else {
            callback(null, result.code)
        }
    })
}